﻿@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>EditPwd</title>
    <link href="~/lib/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
    <link href="~/lib/ligerUI/skins/ligerui-icons.css" rel="stylesheet" type="text/css" />
    <link href="~/lib/ligerUI/skins/Gray/css/all.css" rel="stylesheet" type="text/css" />
    <link href="~/Content/css/common.css" rel="stylesheet" type="text/css" />
    <script src="~/lib/jquery/jquery-1.9.0.min.js" type="text/javascript"></script>
    <script src="~/lib/ligerUI/js/ligerui.all.js"></script>
    <script src="~/Scripts/common.js"></script>
    <script>
        function save() {
            var password = $("#txtPassword").val();
            var newPassword = $("#txtNewPassword").val();
            var confirmPassword = $("#txtConfirmPassword").val();

            if (IsEmpty(password)) {
                $.ligerDialog.error("密码不能为空");
                $("#txtPassword").focus();
                return;
            }

            if (IsEmpty(newPassword)) {
                $.ligerDialog.error("新密码不能为空");
                $("#txtNewPassword").focus();
                return;
            }

            if (IsEmpty(confirmPassword)) {
                $.ligerDialog.error("重复新密码不能为空");
                $("#txtConfirmPassword").focus();
                return;
            }

            if (newPassword != confirmPassword) {
                $.ligerDialog.error("重复新密码不正确");
                $("#txtConfirmPassword").focus();
                return;
            }

            $.ajax({
                url: "/Sysbase/User/EditPwdSave",
                type: "post",
                data: {
                    password: password,
                    newPassword: newPassword
                },
                success: function (r) {
                    var r = $.parseJSON(r);
                    if (r.Result == 1) {
                        $("#txtPassword").val('');
                        $("#txtNewPassword").val('');
                        $("#txtConfirmPassword").val('');
                        $.ligerDialog.success("修改成功");
                        if (frameElement != null) {
                            setTimeout(function () { closeDialog(); }, 1000);
                        }
                    }
                    else if (r.Result == 0) {
                        $.ligerDialog.error(r.Body);
                    }
                    else {
                        $.ligerDialog.error("程序错误");
                    }
                },
                error: function () {
                    $.ligerDialog.error("程序错误");
                }
            });
        }
    </script>
</head>
<body>
    <div style="margin:10px 0px;">
        <table class="gridtable" style="width:350px;">
            <tr>
                <td style="text-align:right; width:100px;">
                    原始密码：
                </td>
                <td>
                    <input type="password" id="txtPassword" class="l-text" style="width:200px;" /><font style="color:red;">&nbsp;*</font>
                </td>
            </tr>
            <tr>
                <td style="text-align:right; width:100px;">
                    新密码：
                </td>
                <td>
                    <input type="password" id="txtNewPassword" class="l-text" style="width:200px;" /><font style="color:red;">&nbsp;*</font>
                </td>
            </tr>
            <tr>
                <td style="text-align:right; width:100px;">
                    重复新密码：
                </td>
                <td>
                    <input type="password" id="txtConfirmPassword" class="l-text" style="width:200px;" /><font style="color:red;">&nbsp;*</font>
                </td>
            </tr>
            <tr>
                <td colspan="2" style="text-align:center;padding-top:10px;">
                    <input id="btnSubmit" type="button" value="确定" class="l-button" onclick="save()" />
                </td>
            </tr>
            <tr></tr>
        </table>
    </div>
</body>
</html>
